<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            background-color: black;
        }

        .con {
            width: 600px;
            height: 30px;
            background-color: white;
            margin: 200px auto;
            border-radius: 20px;
            position: relative;
            overflow: hidden;
        }

        .con .left {
            width: 600px;
            height: 30px;
            position: absolute;
            left: -600px;
            background-image: linear-gradient(120deg, Violet, SkyBlue, LightSeaGreen, green, yellow, orange, red);
        }
    </style>
</head>

<body>
    <div class="con">
        <div class="left"></div>
    </div>
</body>
<script>
    var div = document.querySelector(".left")
    var timer = setInterval(function () {
        if (div.offsetLeft >= -1) {
            clearInterval(timer);
        }
        div.style.left = div.offsetLeft + 1 + 'px';
    }, 30)
</script>

</html>